#ifndef _MELON_CLIENT_ENDPOINT_H_
#define _MELON_CLIENT_ENDPOINT_H_

#include "base/zk_client.h"

namespace melon {
namespace client {

class ZkNodeEndpoint {
 public:
  ZkNodeEndpoint(const std::string & path, base::ZookeeperClient * zk_client);
  ~ZkNodeEndpoint();
  bool Load();

  std::string addr() const {
    return addr_;
  }

  bool enabled() const {
    return enabled_;
  }

  bool healthy() const {
    return healthy_;
  }

  bool active() const {
    return enabled_ && healthy_;
  }
 private:
  std::string path_;
  std::string addr_;
  std::string host_;
  short port_;

  bool enabled_;
  bool healthy_;

  base::ZookeeperClient * zk_client_;

  bool PropIsEnabled(const std::map<std::string, std::string> & props);
  bool PropIsHealthy(const std::map<std::string, std::string> & props);
};
typedef boost::shared_ptr<ZkNodeEndpoint> ZkNodeEndpointPtr;

}
}

#endif // _MELON_CLIENT_ENDPOINT_H_
